/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package persistence;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * This class is a JPA entity and is used to represent a FAQ
 * as it will be stored in the database
 * 
 * @author Amigos do Noddy
 *
 */
@Entity
@Table(name = "FAQ", schema = "APP")
@NamedQueries({@NamedQuery(name = "Faq.findByIdfaq", query = "SELECT f FROM Faq f WHERE f.idfaq = :idfaq"), @NamedQuery(name = "Faq.findByTitle", query = "SELECT f FROM Faq f WHERE f.title = :title"), @NamedQuery(name = "Faq.findByDate", query = "SELECT f FROM Faq f WHERE f.date = :date"), @NamedQuery(name = "Faq.findByAccepted", query = "SELECT f FROM Faq f WHERE f.accepted = :accepted"), @NamedQuery(name = "Faq.findByActive", query = "SELECT f FROM Faq f WHERE f.active = :active")})
public class Faq implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "IDFAQ", nullable = false)
    private Integer idfaq;
    @Lob
    @Column(name = "FAQ", nullable = false)
    private String faq;
    @Column(name = "TITLE", nullable = false)
    private String title;
    @Column(name = "DATE", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date date;
    @Column(name = "ACCEPTED", nullable = false)
    private short accepted;
    @Column(name = "ACTIVE", nullable = false)
    private short active;
    @ManyToMany(mappedBy = "refidfaqCollection")
    private Collection<Administrator> refidpersonAdmCollection;
    @JoinColumn(name = "REFIDPERSON_ASSISTANT", referencedColumnName = "REFIDPERSON")
    @ManyToOne
    private Assistant refidpersonAssistant;

    /**
     * Default constructor
     */
    public Faq() {
    }

    /*public Faq(Integer idfaq) {
        this.idfaq = idfaq;
    }*/

    /*public Faq(Integer idfaq, String faq, String title, Date date, short accepted, short active) {
        this.idfaq = idfaq;
        this.faq = faq;
        this.title = title;
        this.date = date;
        this.accepted = accepted;
        this.active = active;
    }*/

    /**
     * Gets the id of the FAQ
     */
    public Integer getIdfaq() {
        return idfaq;
    }
/*
    public void setIdfaq(Integer idfaq) {
        this.idfaq = idfaq;
    }
*/
    /**
     * Gets the FAQ name
     */
    public String getFaq() {
        return faq;
    }

    /**
     * Sets the FAQ name
     * @param faq faq name
     */
    public void setFaq(String faq) {
        this.faq = faq;
    }

    /**
     * Gets the title of the FAQ
     * @return
     */
    public String getTitle() {
        return title;
    }

    /**
     * Sets the title of the FAQ
     * @param title faq title
     */
    public void setTitle(String title) {
        this.title = title;
    }

    /**
     * Gets the date of the FAQ
     */
    public Date getDate() {
        return date;
    }

    /**
     * Sets the date of the FAQ
     * @param date faq date
     */
    public void setDate(Date date) {
        this.date = date;
    }

    /**
     * Check whether this FAQ was already
     * accepted
     * @return accept status
     */
    public short getAccepted() {
        return accepted;
    }

    /**
     * Sets the accept status of the FAQ
     * @param accepted accept status
     */
    public void setAccepted(short accepted) {
        this.accepted = accepted;
    }

    /**
     * Checks whether this FAQ is active or not
     * @return active status
     */
    public short getActive() {
        return active;
    }

    /**
     * Sets the active status of the FAQ
     * @param active active status
     */
    public void setActive(short active) {
        this.active = active;
    }

    /**
     * Gets the list of administrators that contributed
     * to this FAQ
     */
    public Collection<Administrator> getRefidpersonAdmCollection() {
        return refidpersonAdmCollection;
    }

    /**
     * Sets the list of administrators that contributed
     * to this FAQ
     * @param refidpersonAdmCollection list of administrators
     */
    public void setRefidpersonAdmCollection(Collection<Administrator> refidpersonAdmCollection) {
        this.refidpersonAdmCollection = refidpersonAdmCollection;
    }

    /**
     * Gets the id of the assistant
     */
    public Assistant getRefidpersonAssistant() {
        return refidpersonAssistant;
    }

    /**
     * Sets the id of the assistant
     * @param refidpersonAssistant assistant id
     */
    public void setRefidpersonAssistant(Assistant refidpersonAssistant) {
        this.refidpersonAssistant = refidpersonAssistant;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idfaq != null ? idfaq.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Faq)) {
            return false;
        }
        Faq other = (Faq) object;
        if ((this.idfaq == null && other.idfaq != null) || (this.idfaq != null && !this.idfaq.equals(other.idfaq))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "persistence.Faq[idfaq=" + idfaq + "]";
    }

}
